package datamodels

type Role struct {
	MyGormModel
	PartnerId   uint64   `json:"partner_id,string" gorm:"index;unique_index:_role_name_code_partner_id_scope_id_uc"`
	ScopeId     uint64   `json:"scope_id,string" gorm:"index;default:0;unique_index:_role_name_code_partner_id_scope_id_uc"`
	Partner     *Partner `json:"partner"`
	Code        string   `json:"code" gorm:"size:50;unique_index:_role_name_code_partner_id_scope_id_uc"`
	Name        string   `json:"name" gorm:"size:50;unique_index:_role_name_code_partner_id_scope_id_uc"`
	Description string   `json:"description" gorm:"size:255;"`

	PermissionInfos []*RolePermissionInfo `json:"permission_infos" gorm:"foreignkey:RoleId;"`
	Content 	Json	 `json:"content" gorm:"type: jsonb not null default '{}'::jsonb"`
}

type RolePermissionInfo struct {
	RoleId         uint64      `json:"-" gorm:"index"`
	PermissionId   uint64      `json:"permission_id,string" gorm:"index"`
	NeedAuth       bool        `json:"need_auth" gorm:"default:false"`
	Permission     *Permission `json:"-"`
	PermissionCode string      `json:"permission" gorm:"-"`
}
